package com.example.hello.hello.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;


import com.example.hello.hello.R;
import com.example.hello.hello.animation.ZoomOutPageTransformer;
import com.example.hello.hello.base.BaseFragment;
import com.example.hello.hello.libs.PagerSlidingTabStrip;


public class ServerFragment extends BaseFragment {

    private ViewPager mViewPage;
    private PagerSlidingTabStrip slidingTab;
    private mPagerAdapter adapter;
    private Activity mView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mView = getActivity();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_server;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mViewPage = (ViewPager) mView.findViewById(R.id.content_pager);
        adapter = new mPagerAdapter(getChildFragmentManager());
        mViewPage.setAdapter(adapter);
        mViewPage.setOffscreenPageLimit(2);
        mViewPage.setPageTransformer(true, new ZoomOutPageTransformer());
        slidingTab = (PagerSlidingTabStrip)mView.findViewById(R.id.tabs);
        slidingTab.setTextColorResource(R.color.light_gray_text);
        slidingTab.setDividerColorResource(R.color.common_list_divider);
        slidingTab.setUnderlineColorResource(R.color.common_list_divider);
        slidingTab.setIndicatorColorResource(R.color.titlebackgroud);
        slidingTab.setSelected(true);
        slidingTab.setSelectedTextColor(R.color.titlebackgroud);
        slidingTab.setIndicatorHeight(10);
        slidingTab.setViewPager(mViewPage);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        initTitleBar();
        setMidTxt("服务");
        setRightVisibility(false);
        setLeftVisibility(false);

    }
    private class mPagerAdapter extends FragmentStatePagerAdapter {

        private String Title[] = { "出生", "上学" ,"就业","买房", "结婚" , "就医" , "退休" , "养老" , "其他" };

        public mPagerAdapter(FragmentManager fm) {
            super(fm);
        }
        @Override
        public Fragment getItem(int arg0) {
            int[] id = { 1, 2,3,4,5,6,7,8,9};
            return new BbsFragment();
        }

        @Override
        public int getCount() {
            return Title.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return Title[position];
        }

    }
    @Override
    protected void onClickLeftBtn() {

    }

    @Override
    protected void onClickReghtBtn() {

    }

}
